You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@dstogov Would you prefer if backed_enum_table was part of zend_class_mutable_data? zend_class_entry.backed_enum_table would always be NULL though if mutable data is used, so it seems unnecessary.
@dstogov Would you prefer if backed_enum_table was part of zend_class_mutable_data? zend_class_entry.backed_enum_table would always be NULL though if mutable data is used, so it seems unnecessary.
I didn't get how enums are become mutable, but if we have mutable constant tables for regular classes, we may reuse them for enums as well.
@dstogov To clarify, the enum cases themselves are stored in zend_class_mutable_data.constants_table. zend_class_entry.backed_enum_table in PHP <8.2 has been static. In GH-8190 we moved the compilation of the backed_enum_table to the runtime to allow arbitrary expressions referencing symbols from other files. Like constants we do that on every request. The difference is that when using the inheritance cache zend_class_entry.constants_table contains the constant ASTs while backed_enum_table is just NULL and thus unused, so moving it to zend_class_mutable_data seems useless.
Note that my understanding of the inheritance cache is spotty, so maybe I'm missing something.
Personally I would prefer if backed_enum_table was in zend_class_mutable_data.
Normally any zend_class_entry may be in SHM and should not be modified. Enums disable the inheritance cache so the linked zend_class_entry is not in SHM in this case, but I think that it would improve clarity if the code didn't depend on this knowledge.
@arnaud-lb I decided not to move the backed_enum_table into mutable_data but instead assert that the class is not ZEND_ACC_IMMUTABLE. mutable_data is only used for internal enums because they need to avoid replacing the constant AST of the cases in-place. The backed_enum_table is actually constant and not modified after class construction. For user classes ZEND_ACC_IMMUTABLE is always disabled and thus it's fine to set the backed_enum_table directly. I hope that makes sense.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@dstogov Would you prefer if
backed_enum_tablewas part ofzend_class_mutable_data?zend_class_entry.backed_enum_tablewould always beNULLthough if mutable data is used, so it seems unnecessary.